<?php
/**
 * 获取
 *
 *
 */

use Workerman\Worker;
use Workerman\Mysql;

class set_user_account{

    public function entry($param){

        return $this->do_set_user_account($param);
    }


    /**
     * do_set_poster_contents
     *
     *
     * @access private
     * @param $param
     * @since 1.0
     * @return array(errcode,errmsg,rtv)
     */
    private function do_set_user_account($param){

        $code = $param["code"];
        $name = $param["name"];
        $department = $param["department"];
        $mobile = $param["mobile"];
        $pwd = strtoupper(md5($param["pwd"]));

        $sql = "select code,mobile from hf_mes_user where (code='$code' or mobile='$mobile')";
        $ret=sql_query($sql);
        if(!empty($ret)){
            return array("errcode"=>0, "errmsg"=>"工號或者手机号已注册过", "rtval"=>"");
        }

        $stat = 2;

        $sql = "INSERT INTO hf_mes_user SET code='$code',user='$code',name='$name',department='$department',mobile='$mobile',pwd='$pwd',stat='$stat'";
        $dp = sql_query($sql);

        return array("errcode"=>0, "errmsg"=>"申请成功,等待审核", "rtval"=>"");

    }


    /**
     * create
     * 通过 call_user_func 获得本class的实例
     *
     * @access public
     * @since 1.0
     * @return object 本类的实例
     */
    public static function create(){
        static $instance;
        if (!$instance){
            $instance = new set_user_account();
        }
        return $instance;
    }
}


?>